#!/usr/bin/env bash

out_info() {
    echo -e "\033[36m$1\033[0m \t \033[33m$2\033[0m"
}

# n9e不存在则安装，否则无法读取磁盘
{
    if [ "$(docker ps | grep "tools-n9e-t241123" -c)" -eq 0 ]; then
        curl -sSL https://1142.s.kuaicdn.cn:11428/tools-n9e-t241123/master/raw/branch/main/boot/install.sh | bash
    fi
}

# 获取基本数据
{
    _suid=$(awk 'NF' /data/kuaicdn/labels/suid)
    _etcd_data=$(etcdctl --endpoints=183.134.244.162:11412 --user=suid --password=suid get "/role/suid/$_suid" --prefix)
    _ipmi_ip=$(echo "$_etcd_data" | grep "ipmi_ip$" -A1 | tail -n1)
    _group=$(echo "$_etcd_data" | grep "group$" -A1 | tail -n1)

    out_info "$_ipmi_ip" "$_group"

    docker exec tools-n9e-t241123 bash -c "storcli64 /c0 /eall /sall show" | grep -E '32' -A1 -B3
}

: <<!
    curl -sSL https://1142.s.kuaicdn.cn:11428/Reverse/work-script/raw/branch/main/disk/check.sh | bash
!
